

<template>
    <van-nav-bar :title="title" placeholder fixed border>
        <!-- 左边的内容 -->
        <template #left>
            <div class="back" @click="goback" v-if="!noBack">
                <van-icon name="arrow-left" size="18" />
                <span>返回</span>
            </div>
        </template>
        <!-- 右边的内容 -->
        <template #right v-if="route.name!='search'">
            <van-icon @click="gotopage('/search')" name="search" size="18"/>
        </template>
    </van-nav-bar>
</template>

<script setup>
import {useCommonHook} from '../hooks';
import { useRoute , useRouter } from 'vue-router';
const route = useRoute()    // 路由信息对象
console.log(route);

const router = useRouter()

// 返回上一级
const goback = ()=>{
    router.back()
}

const {
    gotopage
} = useCommonHook()
const props = defineProps({ // 来自父组件的变量 props 组件的外部参数
    title:String,
    noBack:Boolean
})
</script>

<style>
.back{
    color:#1989fa;
}
</style>